<?php
//for stock
try {
    
	$url = "http://api.dddadmin.com/StockService.svc?wsdl";
    $client = new SoapClient($url);
	
	echo '<pre>';
	$shopid = "855001";
	$myKey	= "vkal29xcjs81lslc8qlxpgg63anxaqk2ixkskxm19m";
	
	$params['clientid'] = "855001";
	$params['psk'] = "vkal29xcjs81lslc8qlxpgg63anxaqk2ixkskxm19m";
	
	//$myarticles = file_get_contents('cache.txt');
	//$arrInfo = unserialize($myarticles);
	//$articles = $client->GetWebshopArticles($params);
	$articles = $client->GetWebshopArticles($params);
	$strInfo = ($articles->GetWebshopArticlesResult);
	$arrInfo = json_decode($strInfo);
		
	$paramsstock['eans']	= array();
	$paramsstock['client']	= $shopid;
	$paramsstock['psk']		= $myKey;
	
	foreach($arrInfo as $key=>$value){
		$Ean 			= $value->Ean;
		$arr_ean[] = $Ean;
	}
	
	$paramsstock['eans'] = $arr_ean;
	$arr_stock = $client->StockCount($paramsstock);
	$list_stock = $arr_stock->StockCountResult->KeyValueOflongint;
	file_put_contents('stock.txt',serialize($list_stock));
	
	//foreach($list_stock as $key=>$value){
		//$ean = $value->Key;
		//$onstock = $value->Value;
	//}
	
	
	echo '</pre>';
}
catch (SoapFault $exception) {
    echo $exception->getMessage();
}

//for sale
/*
try {
    $url = "http://api.dddadmin.com/SaleService.svc?wsdl";
    $client = new SoapClient($url);
	
	echo '<pre>';
	echo("Dumping client functions:<BR>");
	//var_dump($client->__getFunctions());
	echo("<BR><BR>");
	$group 	= "855";
	$shopid = "855001";
	$myKey	= "vkal29xcjs81lslc8qlxpgg63anxaqk2ixkskxm19m";
	
	$params['clientid'] 		= "855001";
	$params['psk'] 				= "vkal29xcjs81lslc8qlxpgg63anxaqk2ixkskxm19m";
	$params['customerNumber'] 	= "855";
	$params['datefrom']			= "2013/12/12";
	$params['dateTo']			= "2014/02/01";
	var_dump($params);
	$articles = $client->GetCustomerTransactions($params);
	
	var_dump($articles);
	
	echo '</pre>';
}
catch (SoapFault $exception) {
    echo $exception->getMessage();
}
*/
?>
